using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neitzel;

namespace Neitzel.Tests
{
    /// <summary>
    /// Tests the methods of <see cref="ArrayExtensions"/>.
    /// </summary>
    [TestClass]
    public class ArrayExtensionTests
    {
        /// <summary>
        /// Tests the Equals and GetHashCode methods of <see cref="ArrayExtensions"/>
        /// </summary>
        [TestMethod]
        public void TestEqualsAndHashCode()
        {
            var array1 = new string[] {"Anton", "Berta", "Maier"};
            var array2 = new string[] {"Berta", "Anton", "Maier"};
            var array3 = new string[] {"Anton", "Berta", "Maier"};
            var array4 = new string[] { "Anton", "Berta", "Maier", "Otto" };
            var array5 = new string[] { "Anton", "Berta" };
            var array6 = new string[] { "Anton", "Berta2", "Maier" };

            Assert.IsFalse(ArrayExtensions.Equals(array1, array2));
            Assert.IsTrue(ArrayExtensions.Equals(array1, array3));
            Assert.IsFalse(ArrayExtensions.Equals(array1, array4));
            Assert.IsFalse(ArrayExtensions.Equals(array1, array5));
            Assert.IsFalse(ArrayExtensions.Equals(array1, array6));
            Assert.AreEqual(ArrayExtensions.GetHashCode(array1), ArrayExtensions.GetHashCode(array2));
            Assert.AreEqual(ArrayExtensions.GetHashCode(array1), ArrayExtensions.GetHashCode(array3));
            Assert.AreNotEqual(ArrayExtensions.GetHashCode(array1), ArrayExtensions.GetHashCode(array4));
            Assert.AreNotEqual(ArrayExtensions.GetHashCode(array1), ArrayExtensions.GetHashCode(array5));
            Assert.AreNotEqual(ArrayExtensions.GetHashCode(array1), ArrayExtensions.GetHashCode(array6));
        }
    }
}
